package com.telenav.snowsweeper.data;

import com.telenav.snowsweeper.renderer.Util;

public class Point {
	private int index = -1;
	private int x;
	private int y;
	private int col = -1;
	private int row = -1;
	private int[] screenXY = new int[2];
	private long timeStamp = -1;
	
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
		this.col = Util.x2PointColumn(x);
		this.row = Util.y2PointRow(y);
		this.index = row << 8 | col;
	}
	
	public int getColumn() {
		return col;
	}
	
	public int getRow() {
		return row;
	}
	
	public void getLeftEdgeIndex(int[] out) {
		out[0] = getRow();
		out[1] = getColumn();
	}
	
	public void getRightEdgeIndex(int[] out) {
		out[0] = getRow() - 1;
		out[1] = getColumn();
	}

	public void getTopEdgeIndex(int[] out) {
		out[0] = getRow();
		out[1] = getColumn() - 1;
	}

	public void getBottomEdgeIndex(int[] out) {
		out[0] = getRow(); 
		out[1] = getColumn();
	}
	
	public int getIndex() {
		return index;
	}
	
	public int getX() {
		return x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setScreenXY(int x, int y, long timeStamp) {
		this.screenXY[0] = x;
		this.screenXY[1] = y;
		this.timeStamp = timeStamp;
	}
	
	public int[] getScreenXY(long timeStamp) {
		if (this.timeStamp != timeStamp)
			return null;
		return screenXY;
	}
}
